package com.hfstu.framework.core.orm;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

/**
 * 增，删，改，查，查询所有
 * 
 * @author dejunx
 * 
 * @param <T>
 * @param <ID>
 */
public interface IGenericService<T, ID extends Serializable> {

	/**
	 * 持久化
	 * 
	 * @param entity
	 * @return
	 */
	// 持久化对象
	public abstract T save(T entity);

	public abstract T update(T entity);

	public abstract T saveOrUpdate(T entity);

	/**
	 * 删除
	 * 
	 * @param id
	 */
	public abstract void delete(final ID id);

	/**
	 * 删除
	 * 
	 * @param entity
	 */
	public abstract void delete(T entity);

	// 通过主键标识查找某个对象
	public abstract T getById(final ID id);

	public abstract List<T> getByIds(ID[] ids);

	/**
	 * 查询所有对象
	 * 
	 * @param hql
	 * @return
	 */
	public abstract List<T> findAll();

	public abstract List<T> findListByCondition(Map<String, Object> filterPropertyMap,Map<String, String> sortValueMap);

	public abstract Page<T> findPageByCondition(final PageRequest pageRequest,
			final Map<String, Object> filterPropertyMap,
			final Map<String, String> sortValueMap);

}
